import React from 'react'
import { Icon, Tabs, Form } from 'antd'
import styles from './cms.less'
/**
 * props示例：
 * {
    optList: [
      {
        text: '查看', icon: 'link', type:'view'
      },
      {
        text: '修改', icon: 'edit', type:'edit'
      }
    ],
    handles: {
      viewHandle: (id, index, e) =>{
        console.log('查看');
        dispatch({
          type: 'dict/showDetail',
          payload: {
            currentItem: list[index]
          },
        })
      },
      editHandle: (id, index, e) =>{
        console.log('编辑');
        dispatch({
          type: 'dict/showModal',
          payload: {
            modalType: 'update',
            currentItem: list[index]
          },
        })
      }
    }
    TableView中新增属性id，index
    <ContentMenu optList={optList} handles={handles} id={record.id} index={index}/>
 */

const ContentMenu = (props) => {
  const {optList, handles, index, itemStyle,record} = props;
  let ul_;
  return <ul ref={(node) => ul_ = node} className={styles.uk_content_menu}>
    {
      optList.map(function (item, key) {
        return <li key={key} onClick={handles[item.type + 'Handle'].bind(this, item.text, index, record)} style={itemStyle||null}>
          <Icon type={item.icon}/>{item.text}
        </li>
      })
    }
  </ul>
};

export default ContentMenu
